<?php
/**
 *
 * @author crystal
 * @version 
 */
require_once 'Zend/View/Interface.php';

/**
 * BlockNews helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Zend_View_Helper_PriceFillElement {
	
	/**
	 * @var Zend_View_Interface 
	 */
	public $view;
	
	/**
	 * 
	 */
	public function priceFillElement($priceFill, $role = null) {
        $reg = Zend_Registry::getInstance();
		$res = "";
        
        $colNameStyle = "";
        $colNameStyle .= "background-color: #" . $priceFill['fill_color'] ."; ";
        if (isset($priceFill['file_name'])){
            $colNameStyle .= "background-image: url('" . $this->view->baseUrl(Application_Model_IconService::getInstance()->getIconPath("fill_textures", $priceFill['file_name'], array('y' =>200))) . "')";
        }
        
        $res .= "<div class='price_fill'>";
            $res .= "<div class='fill_name'>";
                $res .= $priceFill['name'];
            $res .= "</div>";
            $res .= "<div class='fill_color' style =\"" . $colNameStyle . "\">";
            $res .= "</div>";
            $res .= "<div class='propertys'>";
                $res .= "<div class='property_wrapper'>";
                    $res .= "<div class='property'>";
                        $res .= "Ціна:";
                    $res .= "</div>";
                    $res .= "<div class='value'>";
                        $res .= $priceFill['price'];
                    $res .= "</div>";
                $res .= "</div>";
                if ($reg->acl->isAllowed($role, 'show_costs')){
                    $res .= "<div class='property_wrapper'>";
                        $res .= "<div class='property'>";
                            $res .= "Собівартість:";
                        $res .= "</div>";
                        $res .= "<div class='value'>";
                            $res .= $priceFill['cost'];
                        $res .= "</div>";
                    $res .= "</div>";
                }
            $res .= "</div>";
            
            $bottomData = "";
    		if ($reg->acl->isAllowed($role, 'remove_system')){
    			$bottomData .= "<div class='button'><a href='" .
    						$this->view->url( array('controller' => 'materials', 'action' => 'delfillprice', 'id' => $priceFill['id'])) .
    						"'>Видалити</a></div>";
            }
    		if ($reg->acl->isAllowed($role, 'edit_system')){
                $bottomData .= "<div class='button'><a href='" .
    						$this->view->url( array('controller' => 'materials', 'action' => 'editfillprice', 'id' => $priceFill['id'])) .
    						"'>Редагувати</a></div>";
    		}
            
            $res .= "<div class='bottom_data'>";
                if ($bottomData != ""){
        			$res .= $bottomData;
        		}
            $res .= "</div>";
        $res .= "</div>";
		return $res;
	}
	
	/**
	 * Sets the view field 
	 * @param $view Zend_View_Interface
	 */
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}
}

